
if (!ToggleImages) {
    var ToggleImages = true; 
}
if (!ToggleImageOpen) {
    var ToggleImageOpen = "url(http://greatindianshuffle.com/images/btnToggleDown.jpg)"; 
}
if (!ToggleImageClose) {
    var ToggleImageClose = "url(http://greatindianshuffle.com/images/btnToggleUp.jpg)"; 
}
if (!ToggleCloseAll) {
    var ToggleCloseAll = true; 
}

function toggleCloseAll(which, whichNotToClose) {

    l = which.childNodes.length;

    for (i=0; i < l; i++) {
        te = which.childNodes[i];

        if (te.className == "ToggleContainer" && te != whichNotToClose) {
            sl = te.childNodes.length;
            for (j=0; j < sl; j++) {
            
                tse = te.childNodes[j];
                if (te.childNodes[j].className) {
                    if (te.childNodes[j].className == "ToggleContent") {
                            te.childNodes[j].style.display = "none";
                    }
                    if (te.childNodes[j].className == "ToggleH2" && ToggleImages) {
                         te.childNodes[j].style.backgroundImage = ToggleImageClose;
                    }
                }
            }               
        }
    }
}

function toggle(which) {
    if (ToggleCloseAll) {
        toggleCloseAll(which.parentNode.parentNode, which.parentNode); 
    }
   
    l = which.parentNode.childNodes.length;
    
    for (i = 0; i < l; i++) {
        cn = which.parentNode.childNodes[i];
        if (cn.className) { 
            if (cn.className == "ToggleH2") {
                title = which.parentNode.childNodes[i];
            }
            if (cn.className == "ToggleContent") {
                content = which.parentNode.childNodes[i];
            }
        }
    }

    if (content.style.display != "inline") {
        content.style.display = "inline";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageOpen;
        }    
    } else {
        content.style.display = "none";
        if (ToggleImages) {
            title.style.backgroundImage = ToggleImageClose;
        }
    }
}

function openToggle(which) {
    
    findElement = document.getElementById(which);
    toggle(findElement)
}
